package com.ymatou.app.api.trading.service;

import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

/***
 * 添加购物车call
 */
public class ScartProdCall extends YmatouBaseCall {
	
	private static String open_url = "api/trading/scartprod";
	
	public ScartProdCall () {
		super(EnvSetup.getSystemUrl(""), open_url, "POST", "PARAM");
	}
	
	@Override
	public void addDefHeader() {
		client.addHeader("Content-Type", "application/json");
		client.addHeader("accept-version", "1.0.0");
		client.addHeader("app_key", "ios");
		client.addHeader("app_version", "2.6.9");
		client.addHeader("deviceid", "8573a814-10f4-4172-89f2-e16a8ce3e89f");
		client.addHeader("timestamp", String.valueOf(System.currentTimeMillis()));
		client.addHeader("sign", "48cc347338f274ebf4c1b09b2e2bec63");
		client.addHeader("ymt_pars", "accesstoken=F56260E33260E56B483563F4AA16BD20BC848C07A3E8D8E6EF3AD31020ED01C0DAB4456BC39E76A0C8E29FC6166A26EA55A3FEAA824B4EAC&format=json&idfa=69cad59b-227b-4a33-80c3-c14d2d200ee0&network=wifi&client=ios&type=buyer&channel=appstore&os=ios9.3&userid=20233860");
	}
	
	/**
	 * 获取totalNum
	 * 
	 * @return
	 */
	public Integer getTotalNum() {
		Integer totalNum = 0;
		
		try {
			totalNum = new JSONObject(getReturnData()).getInt("totalNum");
		} catch(Exception e) {
			e.printStackTrace();
		}
		
		return totalNum;
	}
	
	/**
	 * 获取msg
	 * 
	 * @return
	 */
	public String msg() {
		String msg = null;
		
		try {
			msg = new JSONObject(getReturnData()).getString("msg");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return msg;
	}
	
	/**
	 * 获取success
	 * 
	 * @return
	 */
	public Boolean success() {
		Boolean success = false;
		
		try {
			success = new JSONObject(getReturnData()).getBoolean("success");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return success;
	}
}
